using UnityEngine;

public class LevelSelection : MonoBehaviour
{
	public GameObject[] levels;

	public GameObject terrain1;

	public GameObject terrain2;

	private void Awake()
	{
		SelectLevel();
	}

	public void SelectLevel()
	{
		if (PlayerPrefs.GetInt("selected_level", 0) >= levels.Length)
		{
			PlayerPrefs.SetInt("selected_level", 0);
		}
		terrain1.SetActive(value: false);
		terrain2.SetActive(value: false);
		if (PlayerPrefs.GetInt("selected_level", 0) < 12)
		{
			terrain1.SetActive(value: true);
		}
		else
		{
			terrain2.SetActive(value: true);
		}
		for (int i = 0; i < levels.Length; i++)
		{
			if (PlayerPrefs.GetInt("selected_level", 0) == i)
			{
				levels[i].SetActive(value: true);
				UnityEngine.Debug.Log("level " + i + " activated");
			}
			else
			{
				levels[i].SetActive(value: false);
				UnityEngine.Debug.Log("level " + i + " deactivated");
			}
		}
	}
}
